package com.liwen.service.config;

import com.liwen.api.enums.Ins;
import com.liwen.service.coop.bd.BDService;
import com.liwen.service.coop.jd.JDService;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: li.rui
 * @time: 2017-10-23 16:29
 * @description: 配置不同渠道处理service
 */
public class HandlerConfig {
    private static Map<Ins, String> handlerMap = new HashMap<>();

    static {
        handlerMap.put(Ins.JD, beanName(JDService.class));
        handlerMap.put(Ins.BD, beanName(BDService.class));
    }

    public static String getHandler(Ins ins) {
        return handlerMap.get(ins);
    }

    private static String beanName(Class clz) {
        String name = clz.getSimpleName();
        return name.substring(0, 1).toLowerCase() + name.substring(1);
    }
}
